<template>
	<front-side title="个人中心" :sides="sideList">
		<router-view></router-view>
	</front-side>
</template>

<script>
import store from '@/store';
import frontSide from '@/views/common/frontSide';
export default {
	beforeRouteEnter(to, from, next) {
		let redirect = to.fullPath;
		let isLogin = !!store.getters.token;
		if (!isLogin) {
			next({
				path: '/login',
				query: { redirect }
			});
		} else {
			next();
		}
	},
	components: { frontSide },
	data() {
		return {
			sideList: [
				{
					name: '我的消息',
					color: '#2ab150',
					icon: 'el-icon-my-message',
					path: '/front/userCenter/message'
				},
				{
					name: '拖拽组件',
					color: '#2ab150',
					icon: 'el-icon-my-message',
					path: '/front/userCenter/component'
				}
			]
		};
	},
	computed: {
		routerData() {
			let path = this.$route.fullPath;
			return this.sideList.find((n) => n.path === path);
		}
	}
};
</script>

<style lang="scss" scoped>
.user_center_wrapper {
	position: relative;
	&::before {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 120px;
		content: '';
		z-index: 1;
		background: url('~@/assets/img/bg_usercenter.png') no-repeat center;
		background-size: cover;
	}
}
.user_center_aside {
	position: relative;
	z-index: 2;
	.title {
		display: flex;
		align-items: center;
		justify-content: center;
		line-height: 1;
		font-size: 24px;
		font-weight: bold;
		height: 120px;
		color: #fff;
	}
	.link {
		display: flex;
		align-items: center;
		border-bottom: solid 1px #e4e7ed;
		margin-bottom: 16px;
		a {
			color: #303133;
			font-size: 16px;
			padding: 16px 0;
			margin-left: 16px;
			text-decoration: none;
			box-sizing: border-box;
			border-bottom: solid 2px transparent;
			transition: all 0.3s;
			&:hover {
				color: var(--primary-hover);
			}
			&:first-child {
				margin-left: 0;
			}
			&.router-link-active {
				font-weight: bold;
				color: var(--primary-active);
				border-bottom-color: var(--primary-active);
			}
			i {
				margin-right: 8px;
				&.color1 {
					color: #de422e;
				}
				&.color2 {
					color: #2ab150;
				}
			}
		}
	}
}
.user_center_body {
	flex: 1;
	overflow: hidden;
	border: solid 1px #e4e7ed;
	.header {
		display: flex;
		align-items: center;
		height: 56px;
		font-size: 24px;
		line-height: 1;
		padding: 0 16px;
		background-color: #ecf5ff;
		border-bottom: solid 1px #e4e7ed;
		h2 {
			font-size: 20px;
			line-height: 1;
			font-weight: normal;
			margin-left: 10px;
		}
		i.color1 {
			color: #de422e;
		}
		i.color2 {
			color: #2ab150;
		}
	}
}
@media (min-width: 768px) {
	.user_center_wrapper {
		padding: 152px 0 50px;
		.wrapper {
			position: relative;
			z-index: 2;
			display: flex;
			align-items: flex-start;
		}
	}
	.user_center_aside {
		width: 240px;
		flex-shrink: 0;
		border: solid 1px #e4e7ed;
		.title {
			height: 64px;
			font-size: 24px;
			line-height: 64px;
			font-weight: bold;
			color: #fff;
			text-align: center;
			border-bottom: solid 3px #f0bc1d;
			background-color: var(--primary-active);
		}
		.link {
			align-items: normal;
			flex-direction: column;
			border-bottom: none;
			margin-bottom: 0;
			a {
				display: flex;
				align-items: center;
				justify-content: center;
				height: 56px;
				font-size: 18px;
				margin-left: 0;
				color: #303133;
				border-bottom: none;
				border-top: solid 1px #e4e7ed;
				&:hover,
				&.router-link-active {
					font-weight: normal;
					text-decoration: none;
					background-color: #ecf5ff;
				}
			}
			i {
				margin-right: 8px;
				&.color1 {
					color: #de422e;
				}
				&.color2 {
					color: #2ab150;
				}
			}
		}
	}
	.user_center_body {
		margin-left: 20px;
	}
}
</style>
